package gameObject
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.Responder;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import gameObject.resources3D.GameMesh;
	import gameObject.resources3D.WeaponResource;
	
	import ui.component.EquipIcon;
	
	/**
	 * 机械库，商店中的高模武器
	 */
	public class WeaponPartBase extends GameObjectBase
	{
		public var pid:int;
		public var dur:int=0;
		
		protected var _id:int;
		protected var _inc:int;
		protected var _wName:String;
		protected var _level:int;
		protected var _cost:int;
		protected var _bullet:int;
		protected var _pow:Number
		protected var _speed:Number
		protected var _maxdur:int;
			
		////////////////////////////////////////////////////

		public function get id():int
		{
			return _id;
		}

		public function get inc():int
		{
			return _inc;
		}

		public function get cost():int
		{
			return _cost;
		}
		public function get sellCost():int
		{
			var val:int;
			val = 0.6*cost;
			val *= dur/maxdur;
			
			return val;
		}
		public function get maxdur():int
		{
			return _maxdur;
		}

		public function get speed():Number
		{
			return _speed;
		}

		public function get pow():Number
		{
			return _pow;
		}

		public function get bullet():int
		{
			return _bullet;
		}

		public function get level():int
		{
			return _level;
		}

		override public function get name():String
		{
			return _wName;
		}
		
		
		////////////////////////////////////////////////////
		/**
		 * @param ID
		 * 编号申请后就没得变了
		 */
		public function WeaponPartBase(ID:int,inc:int)
		{
			super();
			_id = ID;
			_inc = inc;
		}
		
		override public function dispose():void
		{
			super.dispose();
			if(_resource)_resource.dispose();
		}
		
		public function displayModel():void
		{
			if(_resource)addChild(_resource)
			else
			{
				addEventListener(Event.COMPLETE,displayModelEvent);
				function displayModelEvent(e:Event):void
				{
					addChild(_resource);
				}
			}
		}
		
		public function hideModel():void
		{
			if(_resource)
			{
				addChild(_resource);//免得没显示模型时使用这个方法报错
				removeChild(_resource);
			}
		}
		////////////////////////////////////////////////////
		
	}
}